package com.czx.drivingtest.controller;

import com.czx.drivingtest.model.ResponseData;
import com.czx.drivingtest.model.entity.TokenInfo;
import com.czx.drivingtest.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户认证控制器
 * @author czx
 * @version 2020/6/8 10:45 下午
 * @since JDK12
 */
@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private AuthService authService;
    /**
     * 用户登录
     * @param jsCode
     * @return
     */
    @PostMapping("/login")
    public ResponseData<TokenInfo> login(String jsCode) {
        TokenInfo tokenInfo = authService.login(jsCode);
        return new ResponseData<>(0, "success", tokenInfo);
    }
}
